//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2021 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto/tree/main/CodeGenerator. DO NOT EDIT.

import SotoCore

/// Error enum for IoTSiteWise
public struct IoTSiteWiseErrorType: AWSErrorType {
    enum Code: String {
        case conflictingOperationException = "ConflictingOperationException"
        case internalFailureException = "InternalFailureException"
        case invalidRequestException = "InvalidRequestException"
        case limitExceededException = "LimitExceededException"
        case resourceAlreadyExistsException = "ResourceAlreadyExistsException"
        case resourceNotFoundException = "ResourceNotFoundException"
        case serviceUnavailableException = "ServiceUnavailableException"
        case throttlingException = "ThrottlingException"
        case tooManyTagsException = "TooManyTagsException"
        case unauthorizedException = "UnauthorizedException"
    }

    private let error: Code
    public let context: AWSErrorContext?

    /// initialize IoTSiteWise
    public init?(errorCode: String, context: AWSErrorContext) {
        guard let error = Code(rawValue: errorCode) else { return nil }
        self.error = error
        self.context = context
    }

    internal init(_ error: Code) {
        self.error = error
        self.context = nil
    }

    /// return error code string
    public var errorCode: String { self.error.rawValue }

    /// Your request has conflicting operations. This can occur if you're trying to perform more than one operation on the same resource at the same time.
    public static var conflictingOperationException: Self { .init(.conflictingOperationException) }
    /// AWS IoT SiteWise can't process your request right now. Try again later.
    public static var internalFailureException: Self { .init(.internalFailureException) }
    /// The request isn't valid. This can occur if your request contains malformed JSON or unsupported characters. Check your request and try again.
    public static var invalidRequestException: Self { .init(.invalidRequestException) }
    /// You've reached the limit for a resource. For example, this can occur if you're trying to associate more than the allowed number of child assets or attempting to create more than the allowed number of properties for an asset model. For more information, see Quotas in the AWS IoT SiteWise User Guide.
    public static var limitExceededException: Self { .init(.limitExceededException) }
    /// The resource already exists.
    public static var resourceAlreadyExistsException: Self { .init(.resourceAlreadyExistsException) }
    /// The requested resource can't be found.
    public static var resourceNotFoundException: Self { .init(.resourceNotFoundException) }
    /// The requested service is unavailable.
    public static var serviceUnavailableException: Self { .init(.serviceUnavailableException) }
    /// Your request exceeded a rate limit. For example, you might have exceeded the number of AWS IoT SiteWise assets that can be created per second, the allowed number of messages per second, and so on. For more information, see Quotas in the AWS IoT SiteWise User Guide.
    public static var throttlingException: Self { .init(.throttlingException) }
    /// You've reached the limit for the number of tags allowed for a resource. For more information, see Tag naming limits and requirements in the AWS General Reference.
    public static var tooManyTagsException: Self { .init(.tooManyTagsException) }
    /// You are not authorized.
    public static var unauthorizedException: Self { .init(.unauthorizedException) }
}

extension IoTSiteWiseErrorType: Equatable {
    public static func == (lhs: IoTSiteWiseErrorType, rhs: IoTSiteWiseErrorType) -> Bool {
        lhs.error == rhs.error
    }
}

extension IoTSiteWiseErrorType: CustomStringConvertible {
    public var description: String {
        return "\(self.error.rawValue): \(self.message ?? "")"
    }
}
